package com.quan.commons.log.event;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import com.quan.admin.entity.SysLog;
import com.quan.admin.service.SysLogService;

import lombok.RequiredArgsConstructor;

/**
 * 异步监听日志事件
 */
@Component
@RequiredArgsConstructor
public class SysLogListener {

	@Autowired
	private SysLogService sysLogService;

	@Async
	@Order
	@EventListener(SysLogEvent.class)
	public void saveSysLog(SysLogEvent event) {
		SysLog sysLog = (SysLog) event.getSource();
		this.sysLogService.save(sysLog);
	}

}
